﻿using System.Collections.Generic;
using System.Security.Claims;
using System.Security.Principal;

using Microsoft.AspNetCore.Http;

namespace Microsoft.AspNetCore.Mvc
{
    public abstract class AuthIdentity : ClaimsIdentity
    {
        public override string AuthenticationType => this.GetType().Name;
        public override bool IsAuthenticated => true;
   
        public abstract bool Deserialize(byte[] data, HttpContext httpContext);

        public virtual bool IsInRight(string rightCode, int rightKey = 0)
        {
            return true;
        }

        public bool IsInRight(string rightCode, RightKey rightKey)
        {
            return IsInRight(rightCode, (int)rightKey);
        }

        public abstract byte[] Serialize();

    }


    public enum RightKey : int
    {
        Owner = 1,
        Add = 2,
        Edit = 4,
        Delete = 8,
        Import = 16,
        Export = 32,
        Special = 64
    }
}
